Be sure the 'is not a crate root' message shows up
authorAlex Crichton <alex@alexcrichton.com>
Mon, 25 Jan 2016 18:41:44 +0000 (10:41 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 25 Jan 2016 18:41:44 +0000 (10:41 -0800)
src/cargo/ops/cargo_install.rs
tests/test_cargo_install.rs

index 8d51d7cd1552e951ffe2c834f2509e56d2094f45..57f94f223f04daab02d7c3721e7556c558971914 100644 (file)
@@ -50,13 +50,15 @@ pub fn install(root: Option<&str>,
     } else if source_id.is_path() {
         let path = source_id.url().to_file_path().ok()
                             .expect("path sources must have a valid path");
+        let mut src = PathSource::new(&path, source_id, config);
+        try!(src.update().chain_error(|| {
+            human(format!("`{}` is not a crate root; specify a crate to \
+                           install from crates.io, or use --path or --git to \
+                           specify an alternate source", path.display()))
+        }));
         try!(select_pkg(PathSource::new(&path, source_id, config),
                         source_id, krate, vers,
-                        &mut |path| path.read_packages())
-                 .chain_error(|| human(format!("`{}` is not a crate root; specify a \
-                                                crate to install from crates.io, or \
-                                                use --path or --git to specify an \
-                                                alternate source", path.display()))))
+                        &mut |path| path.read_packages()))
     } else {
         try!(select_pkg(RegistrySource::new(source_id, config),
                         source_id, krate, vers,
index 85022ba2cbcdc81b564b8bd3145252f7aa2c155a..f5e42c99408f18dc12fbcb3e8cc03d4deb035dd5 100644 (file)
@@ -120,7 +120,10 @@ could not find `foo` in `registry file://[..]` with version `0.2.0`
 test!(no_crate {
     assert_that(cargo_process("install"),
                 execs().with_status(101).with_stderr("\
-Could not find Cargo.toml in `[..]`
+`[..]` is not a crate root; specify a crate to install [..]
+
+Caused by:
+  Could not find Cargo.toml in `[..]`
 "));
 });